package net.yambal.android.secretary_alarm.file;

import java.io.File;
import java.util.List;

import net.yambal.android.util.StringUtil;

import android.util.Log;

public class VoiceDownloader{
	//private ListenerFileDownloader _cliant;
	
	public VoiceDownloader(){
		//_cliant = cliant;
	}
	
	public List<File> download(String txt, String download_to_dir, String download_to_filename, String word){
		Log.d("sa", "download@VoiceDownloader txt:" + txt);
		
		List<String> lines = StringUtil.textSplitter(txt, 100);
		
		String[] urls = new String[lines.size()];
		int i = 0;
		while(lines.size() > 0){
			String line = lines.remove(0);
			String enc = StringUtil.UrlEncode(line);
			if(!enc.equals(null)){
				urls[i] = "http://translate.google.co.jp/translate_tts?ie=UTF-8&q="+enc+"&tl=ja";
			}
			i++;
		}
		
		FileDownloader file_downloader = new FileDownloader();
		return file_downloader.download(urls, download_to_dir, download_to_filename);
	}

	/**
	public void onDownloaded(List<File> downloadedFiles, String word) {
		Log.w("sa", "VoiceDownloader.onDownloaded");
		Log.w("sa", " - " + downloadedFiles);
		if(downloadedFiles != null){
			Log.w("sa", " - " + downloadedFiles.size());
		}
		_cliant.onDownloaded(downloadedFiles, word);
	}

	
	public void onDownloadFault() {
		_cliant.onDownloadFault();
	}
	**/
}
